package vinh.game;

public class Shuttle extends PolygonSprite {
	
	public double speed = 1.0;
	
	public Shuttle(){
		//design of the shape of the polygon shuttle
		this.shape.addPoint(0,-10);
		this.shape.addPoint(7, 10);
		this.shape.addPoint(-7, 10);
		//starting angle
		this.angle = Math.PI/2;
	}
	
	//redefine the behaviour of the advance method. makes the shuttle reappear when it goes out of bounds
	@Override
	public void advance(int width, int height, double speed){
		this.angle += this.delta_angle;
		if (this.angle < 0)
			this.angle += 2*Math.PI;
		if (this.angle > 2 * Math.PI)
			this.angle -= 2 * Math.PI;
		
		this.x += this.delta_x;
		if (this.x < 0)
			this.x += width;
		if (this.x > width)
			this.x -= width;
		
		this.y -= this.delta_y;
		if(this.y < 0)
			this.y += height;
		if(this.y > height)
			this.y -= height;
	}
	
	public void init(int width, int height){
		// Reset the sprite at the center of the screen.
		this.active = true;
		this.angle = 0.0;
		this.delta_angle = 0.0;
		this.x = width/2;
		this.y = height/2;
		this.delta_x = 0.0;
		this.delta_y = 0.0;
	}
	
	
}
